<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

<p> use base64 upload file</p>

<input type="file" id="to_upload"/>
<img id="img" src=""/>

<div id="base"></div>

<script src="/js/jquery.js"></script>
<script src="/js/index.js"></script>
<script type="text/javascript">
    function readImage() {
        if (this.files && this.files[0]) {
            var FR = new FileReader();
            FR.onload = function (e) {
                $('#img').attr("src", e.target.result);
                $('#base').text(e.target.result);
                postBase64Img(e.target.result, function (err, data) {
                    if (err)console.log('err', err);
                    if (data)console.log('data', data);
                });
            };
            FR.readAsDataURL(this.files[0]);
        }
    }

    $("#to_upload").on('change', readImage);
</script>
</body>
</html>